home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / clonecd / September 93.img / Archives / Decoration / Screensavers / Screen Savers / TwilightZone / source / trapavailable.c < prev    next >
Text File  |  1992-06-01  |  1KB  |  58 lines

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * Simple Sample Application Framework
  4.  *
  5.  * ©1991 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * trapavailable.c -- checks to see if a trap is implemented
  10.  *
  11.  * change history:
  12.  *
  13.  * SJF        11/6/91        1.0d1        initial coding
  14.  *
  15.  */
  16.  
  17. #include <Types.h>
  18. #include <Traps.h>
  19. #include <OSUtils.h>
  20. #include <GestaltEqu.h>
  21.  
  22. #include "trapavailable.h"
  23.  
  24. short NumToolboxTraps(void);
  25. TrapType GetTrapType(short theTrap);
  26.     
  27. short NumToolboxTraps(void)
  28. {
  29.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  30.         return 0x0200;
  31.     else
  32.         return 0x0400;
  33. }
  34.  
  35. TrapType GetTrapType(short theTrap)
  36. {
  37.     if ((theTrap & 0x0800) > 0)
  38.         return ToolTrap;
  39.     else
  40.         return OSTrap;
  41. }
  42.  
  43. Boolean    TrapAvailable(short theTrap)
  44. {
  45.     TrapType tType;
  46.     Boolean isAvail;
  47.     
  48.     tType = GetTrapType(theTrap);
  49.     if (tType == ToolTrap)
  50.         {
  51.             theTrap &= 0x07FF;
  52.             if (theTrap >= NumToolboxTraps())
  53.                 theTrap = _Unimplemented;
  54.         }
  55.     
  56.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  57.     return isAvail;
  58. }